package speedball;

import javafx.scene.control.Button;
import javafx.scene.control.Label;
import javafx.scene.image.ImageView;
import javafx.scene.paint.Color;
import javafx.scene.text.Font;

public class ControlManage {

	private static Font font1 = new Font("Ebrima", 12.0D);
	private static Font font2 = new Font("Ebrima", 28.0D);

	public static Label createNumber(double layoutX, double layoutY, double width, double height, Color color) {
		Label number = labelWithLocation("99", font2, layoutX, layoutY, width, height, color);
		return number;
	}

	public static Label createPercent(double layoutX, double layoutY, double width, double height) {
		Label percent = labelWithLocation("%", font1, layoutX, layoutY, width, height);
//		Label percent = label("%",font1,circleSize * 0.2D + 1,circleSize * 0.6D + 5D,circleSize * 2.0D * 0.4D,circleSize * 2.0D * 0.4D);
		return percent;
	}

	public static Label labelWithLocation(String text, Font font, double layoutX, double layoutY, double width, double height,
			Color color) {
		Label label = labelWithLocation(text, font, layoutX, layoutY, width, height);
		if (color != null) {
			label.setTextFill(color);
		}

		return label;
	}

	
	
	
	
	public static Label labelWithLocation(String text, Font font, double layoutX, double layoutY, double width, double height) {
		Label label = new Label();
		label.setText(text);
		label.setFont(font);
		label.setLayoutX(layoutX);
		label.setLayoutY(layoutY);
		label.setPrefWidth(width);
		label.setPrefHeight(height);
		return label;
	}
	
	public static Label label(String text,Font font,double width, double height,
			Color color) {
		Label label = label(text,color);
		label.setFont(font);
		label.setPrefWidth(width);
		label.setPrefHeight(height);
		return label;
	}
	
	public static Label label(String text,
			Color color) {
		Label label = new Label(text);
		if (color != null) {
			label.setTextFill(color);
		}

		return label;
	}

	/**
	 * 创建扩展按钮
	 * 
	 * @param layoutX
	 * @param layoutY
	 * @param width
	 * @param image
	 * @return
	 */
	public static Button createExpand(double layoutX, double layoutY, double width, ImageView image) {
		Button expand = new Button();

		expand.setPrefWidth(width);
		expand.setPrefHeight(width);
		expand.setMaxWidth(width);
		expand.setMaxHeight(width);
		expand.setMinWidth(width);
		expand.setMinHeight(width);
//			expand.setText("+");
		if (image != null) {
			expand.setGraphic(image);
		}
		expand.setOnAction(event -> {
//				handleButtonAction(event);
		});
		expand.setLayoutX(layoutX);
		expand.setLayoutY(layoutY);
		expand.setStyle("-fx-border-radius: 25; -fx-background-radius: 25; -fx-background-color: #3399FF;");
		return expand;

	}
}
